package com.tech.pattern.annotation;

import com.tech.pattern.factory.factoryfunc.Fruit;

import java.io.File;
import java.lang.reflect.Field;

/**
 * @Description:
 * @Author: zl
 * @Date: 2019/7/11 23:13
 */
public class FruitInfoUtil {

    public static void getFruit(Class<?> clazz) {
        String strFruitProvicer = "";
        Field[] fields = clazz.getDeclaredFields();//通过反射获取处理注解
        for (Field field : fields) {
            if (field.isAnnotationPresent(FruitProvider.class)) {
                FruitProvider fruitProvider = (FruitProvider) field.getAnnotation(FruitProvider.class);
//注解信息的处理地方
                strFruitProvicer = " 供应商编号： " + fruitProvider.id() + " 供应商名称： "
                        + fruitProvider.desc() + " 供应商地址： " + fruitProvider.address();
                System.out.println(strFruitProvicer);
            }
        }
    }
}


